package io.github.annyylxyms.gyncache.command;

import io.github.annyylxyms.gyncache.core.Command;
import io.github.annyylxyms.gyncache.core.GynCache;
import io.github.annyylxyms.gyncache.core.Reply;

/**
 *
 * @author Anny
 * @date 2025/1/15 20:41
 */
public class ZrankCommand implements Command {
    @Override
    public String name() {
        return "ZRANK";
    }

    /**
     * 返回排名的顺序
     * @param cache
     * @param args
     * @return
     */
    @Override
    public Reply<?> exec(GynCache cache, String[] args) {
        String key = getKey(args);
        String val = getValue(args);
        return Reply.integer(cache.zrank(key,val));
    }
}
